function GetHospital () {
    var obj = this;
    var hospitalModal = null;

    var hospitalModalHtml = '<div id="hospitalModal" style="display: none;">'
        +     '<div class="box-body hospital-content" style="margin:5px 0 -10px 0">'
        +        '<div class="row">'
        +            '<div class="col-md-4">'
        +                '<div class="form-group" >'
        +                    '<select name="regionId" class="form-control regionId" style="width: 100%;"></select>'
        +                '</div>'
        +            '</div>'
        +            '<div class="col-md-4">'
        +                '<div class="form-group" >'
        +                    '<select name="cityId" class="form-control cityId" style="width: 100%;"></select>'
        +                '</div>'
        +            '</div>'
        +            '<div class="col-md-4">'
        +                '<div class="form-group" >'
        +                    '<select name="areaId" class="form-control areaId" style="width: 100%;"></select>'
        +                '</div>'
        +            '</div>'
        +            '<div class="col-md-4">'
        +                '<div class="form-group">'
        +                    '<input name="hospitalAll" class="form-control hospitalAll" placeholder="医院名称/医院编号" type="text"/>'
        +                '</div>'
        +            '</div>'
        +            '<div class="col-md-2 pull-right">'
        +                '<div class="form-group pull-right">'
        +                    '<button name="search" type="button" class="btn btn-info btn-sm" style="margin-right:5px" data-toggle="tooltip" data-placement="bottom" title="">搜索</button>'
        +                    '<button name="select" type="button" class="btn btn-info btn-sm" data-toggle="tooltip" data-placement="bottom" title="">确定</button>'
        +                '</div>'
        +            '</div>'
        +        '</div>'
        +   '</div>'
        +   '<div class="box-body no-padding table-responsive" style="max-height:400px;overflow:auto">'
        +        '<table class="table table-bordered table-striped hospital-list"><thead>'
        +           '<tr class="info">'
        +               '<th class="text-left text-muted" style="width: 35px"><div>#</div></th>'
        +               '<th class="text-left text-muted" style="width: 35px">选择</th>'
        +               '<th class="text-left text-muted td-width">医院名称</th>'
        +               '<th class="text-left text-muted  td-width">医院编号</th>'
        +               '<th class="text-left text-muted  td-width">省份-城市-区域</th>'
        +               '<th class="text-left text-muted td-width">联系人</th>'
        +               '<th class="text-left text-muted td-width">联系电话</th>'
        +               '<th class="text-left text-muted td-width">详细地址</th>'
        +           '</tr>'
        +       '</thead>'
        +       '<tbody>'
        +           '<tr>'
        +               '<td class="text-center text-muted" style="width: 30px">1</td>'
        +               '<td style="width:35px">\
                        <input type="checkbox" class="flat-green" name="hospital">\
                        </td>'
        +               '<td class="text-center text-muted">红房子医院</td>'
        +               '<td class="text-center text-muted">HFZ23727112</td>'
        +               '<td class="text-center text-muted">上海市-上海市-杨浦区</td>'
        +               '<td class="text-center text-muted">张三</td>'
        +               '<td class="text-center text-muted">13812345678</td>'
        +               '<td class="text-center text-muted">沈阳路1231号</td>'
        +           '</tr>'
        +           '<tr>'
        +               '<td class="text-center text-muted" style="width: 30px">2</td>'
        +               '<td style="width:35px">\
                        <input type="checkbox" class="flat-green" name="hospital">\
                        </td>'
        +               '<td class="text-center text-muted">上海宝山仁和医院</td>'
        +               '<td class="text-center text-muted">HFZ23727112</td>'
        +               '<td class="text-center text-muted">上海市-上海市-宝山区</td>'
        +               '<td class="text-center text-muted">张三</td>'
        +               '<td class="text-center text-muted">13812345678</td>'
        +               '<td class="text-center text-muted">沈阳路1231号</td>'
        +           '</tr>'
        +       '</tbody></table>'
        +   '</div>'
        +   '<div class="box-footer clearfix"><div class="M-box2 text-center hospital-page"></div></div>'
        + '</div>';

    this.init = function (fn) {
        obj.appendHtml();
        obj.initModal();
        obj.bindEvent(fn);
        obj.initCheckbox();
        return obj;
    };

    this.appendHtml = function () {
        $('.content-wrapper').append(hospitalModalHtml);
        hospitalModal = $('#hospitalModal');
    };
    this.initModal = function () {
        hospitalModal.iziModal({
            title: '选择医院',
            headerColor: '#00c0ef',
            theme: '',  // light
            attached: '', // bottom, top
            icon: null,
            iconText: null,
            iconColor: '',
            rtl: false,
            width: 1000,
            padding: 0,
            zindex: 1048,
            iframe: false,
            iframeHeight: 400,
            iframeURL: null,
            focusInput: false,
            group: '',
            loop: false,
            navigateCaption: true,
            navigateArrows: true, // closeToModal, closeScreenEdge
            history: false,
            restoreDefaultContent: false,
            autoOpen: false, // Boolean, Number
            bodyOverflow: false,
            fullscreen: true,
            openFullscreen: false,
            closeOnEscape: false,
            overlay: true,
            overlayClose: false,
            overlayColor: 'rgba(0, 0, 0, 0.4)',
            timeout: false,
            timeoutProgressbar: false,
            pauseOnHover: false,
            timeoutProgressbarColor: 'rgba(255,255,255,0.5)',
            transitionIn: 'comingIn',
            transitionOut: 'comingOut',
            transitionInOverlay: 'fadeIn',
            transitionOutOverlay: 'fadeOut',
            onOpening: function(){
                obj.initSelect();
                obj.getHospitalList(0, 10);
            },
            onOpened: function(){
            },
            onClosing: function(){},
            onClosed: function(){
                hospitalModal.remove();
            }
        });
        hospitalModal.iziModal('open');
    };

    this.initSelect = function () {
        hospitalModal.find('.regionId').select2({
            language: 'zh-CN',
            allowClear: true,
            placeholder: '请选择省份'
        });
        hospitalModal.find('.cityId').select2({
            language: 'zh-CN',
            allowClear: true,
            placeholder: '请选择城市'
        });
        hospitalModal.find('.areaId').select2({
            language: 'zh-CN',
            allowClear: true,
            placeholder: '请选择区域'
        });
    };

    this.initCheckbox = function () {
        $('.flat-green').iCheck({
            checkboxClass: 'icheckbox_flat-green',
            radioClass: 'iradio_flat-green'
        });
        $("input[name='total']").on('ifChecked', function(event){
            $("input[name='device']").each(function(){
                console.log("abc");
            });
        });

        $("input[type='checkbox'][name='total']").on('ifClicked', function(event){
            $("input[type='checkbox'][name='one']").iCheck($(this).is(':checked')?'uncheck':'check');
        });
        $("input[type='checkbox'][name='one']").on('ifChecked', function(event){
            var change = true;
            $("input[type='checkbox'][name='one']").each(function(){
                if($(this).is(':checked')==false){
                    change = false;
                }else{
                    if(idMap.get($(this).val()) == null){
                        idMap.put($(this).val(),$(this).val());
                    }
                }
            });
            if(change){
                $("input[type='checkbox'][name='total']").iCheck('check');
            }
        });

        $("input[type='checkbox'][name='one']").on('ifUnchecked', function(event){
            if($("input[type='checkbox'][name='total']").is(":checked")){
                $("input[type='checkbox'][name='total']").iCheck('uncheck');
            }
            if(idMap.get($(this).val())!= null){
                idMap.remove($(this).val());
            }
        })
    };

    this.bindEvent = function (fn) {
        hospitalModal.find('.regionId').on('change', function () {
            obj.getCity($(this).val());
            hospitalModal.find('.areaId').empty();
        });
        hospitalModal.find('.cityId').on('change', function () {
            obj.getArea(hospitalModal.find('.regionId').val(), $(this).val());
        });

        hospitalModal.find('[name="search"]').click(function () {
            obj.getHospitalList();
        });

        hospitalModal.find('[name="select"]').click(function () {
            var chechedInpt = hospitalModal.find("input[name='hospital']:checked");
            if(chechedInpt.length > 0){
                $("#hospitalTextarea").text("红房子医院,上海宝山仁和医院");
                hospitalModal.iziModal('close');
            }else{
                flavrShowByTime("请选择医院", null, "danger", false);
            }
        })
    };

    this.getHospitalList = function (start,limit,orderby,sorting) {
        var table = hospitalModal.find("table");
        var params = {
            start: start,
            end: limit,
            orderby: orderby,
            sorting: sorting,
            regionId: hospitalModal.find('.regionId').val(),
            cityId: hospitalModal.find('.cityId').val(),
            areaId: hospitalModal.find('.areaId').val(),
            hospitalAll: hospitalModal.find('.hospitalAll').val()
        };
    };

    var $start = 0;
    var $limit = 10;
    this.page = function(total,limit,current,obj){
        hospitalModal.find('.hospital-page').empty().pagination({
            totalData:total,
            showData:limit,//数据总数totalData和每页显示的条数showData必须同时配置，否则默认使用总页数pageCount;limit可选值 5 10 20 50
            //pageCount:50,
            current:current,
            jump:true,
            coping:true,
            homePage:'首页',
            endPage:'末页',
            prevContent:'上页',
            nextContent:'下页',
            callback:function(index){
                $start = start = (index.getCurrent()-1)*limit;
                $limit = limit = index.getShowData();
                //$('.now').text(index);
                obj.getHospitalList(start,limit);
            }
        });
    };

    this.clearHospital = function (FormId) {
        $('#' + FormId).find('input[name="hospitalId"]').change(function () {
            if($(this).val() && ($(this).nextAll('i.clear-hospital').length < 1)) {
                $(this).parent().css('position','relative').append('<i class="clear-hospital" ' +
                    'style="position:absolute;top:8px;right:45px;z-index:5;cursor: pointer;font-size:14px;font-weight: bold;' +
                    'font-family: \'Source Sans Pro\', \'Helvetica Neue\', Helvetica, Arial, sans-serif;">×</i>');
            }
        }).parent().on('click', 'i.clear-hospital', function (){
            $(this).prevAll('input').val('').trigger('change');
            $(this).remove();
        });
    };
}